class cocktailSort
{
    public:
        void sort( int* arr, int len )
        {
        bool notSorted = true;
        while( notSorted ){
            notSorted = false;
            for( int a = 0; a < len - 1; a++ ){
                if( arr[a] > arr[a + 1] ){
                    sSwap( arr[a], arr[a + 1] );
                    notSorted = true;
                }
            }
    
            if( !notSorted ) break;
            notSorted = false;
    
            for( int a = len - 1; a > 0; a-- ){
                if( arr[a - 1] > arr[a] ){
                    sSwap( arr[a], arr[a - 1] );
                    notSorted = true;
                }
            }
        }
        }
    
    private:
        void sSwap( int& a, int& b ){
            int t = a;
            a = b; b = t;
        }
};